package com.inter.utils.mail;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

/**
 * <Description> 邮件定时发送
 *
 * @author WEIQI
 * @version V1.0
 * @createDate 2019-06-14 17:06
 * @see
 */
@Component
@EnableScheduling
public class SendMailTask {

    private static Log log = LogFactory.getLog(SendMailTask.class);

    @Autowired
    JavaMailSenderImpl javaMailSender;

    //@Value("${mail.subject}")
    String subject;
    //@Value("${mail.sendText}")
    String sendText;

    /**
     * Description 邮件发送定时任务，示例中每隔五秒执行一次
     *
     * @param
     * @author WEIQI
     * @createDate 2019/6/14 17:38
     **/
    //@Scheduled(cron = "*/5 * * * * ?")

    public void timingSendMail() {
        log.info("*** 邮件发送定时任务 ***");
        //javaMailSender.send(new SendMailUtil().sendIdentifyingCode(subject, sendText));

        String sendText = "卡片ICCID:89860220191018003469" + "\n" +
                "套餐名称:中国+欧盟28国30M后付费月流量套餐" + "\n" +
                "订单编码:L202001100000731845" + "\n" +
                "操作类型:" + "提前结束订单" + "\n" +
                "异常描述:" + "" + "\n";
        javaMailSender.send(new SendMailUtil().sendIdentifyingCode("赠送套餐处理异常", sendText));

    }

}
